﻿/*
 *  Author: Louis A. Leskoviansky
 *  Company: Artemis Solutions Group (http://www.artemis-solutions.com)
 */


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.UI;

[assembly: WebResource("AjaxControlFramework.UpdateRegion.debug.js", "application/x-javascript")]
[assembly: WebResource("AjaxControlFramework.UpdateRegion.release.js", "application/x-javascript")]

namespace AjaxControlFramework
{
    public class UpdateRegionScriptStrategy : ControlScriptStrategy
    {
        //------// Properties \\--------------------------------------------\\
        public virtual string BaseControlScriptName
        {
            get
            {
                if (BuildMode == ScriptBuildMode.Debug)
                {
                    return "AjaxControlFramework.UpdateRegion.debug.js";
                }
                else
                {
                    return "AjaxControlFramework.UpdateRegion.release.js";
                }
            }
        }
        //------\\ Properties //--------------------------------------------//



        //------// Constructors \\------------------------------------------\\
        public UpdateRegionScriptStrategy(Control targetControl)
			: base(targetControl)
		{ }


        public UpdateRegionScriptStrategy(Control targetControl, ScriptBuildMode buildMode)
			: base(targetControl, buildMode)
		{ }
        //------\\ Constructors //------------------------------------------//



        //------// Methods \\-----------------------------------------------\\
        public override void RegisterFrameworkScript()
        {
            base.RegisterFrameworkScript();

            EmbeddedScriptReference controlScriptReference = new EmbeddedScriptReference(GetType().Name, BaseControlScriptName, "AjaxControl");
            controlScriptReference.Dependencies.Add("System.Web.WebForms");
            controlScriptReference.Dependencies.Add(FrameworkScriptName);

            InternalScriptManager.Instance.RegisterScript(controlScriptReference, ScriptRenderLocation.Body);
        }


        public override void GenerateControlScript(ref TextWriter writer)
        {
            /* Do nothing. */
        }
        //------\\ Methods //-----------------------------------------------//
    }
}
